#include "stm32f4xx.h"                  // Device header
#include "DELAY.h"
/**********************************
Function:DELAY_ms
Retrun:None
Pram:uint32_t
**********************************/

void DELAY_ms(uint32_t xms)
{
    while(xms--)
    {
        SysTick->CTRL = 0;
        SysTick->LOAD = SystemCoreClock/1000;
        SysTick->VAL = 0;
		SysTick->CTRL = 5;
		while ((SysTick->CTRL & 0x00010000)==0);
		SysTick->CTRL = 0;    
    }
}
/**********************************
Function:DELAY_us
Retrun:None
Pram:uint32_t
**********************************/
void DELAY_us(uint32_t xus)
{
	while(xus--)
	{
		SysTick->CTRL = 0;
		SysTick->LOAD = SystemCoreClock/1000/1000;//1MHZ = 1uS
		SysTick->VAL = 0;
		SysTick->CTRL = 5;
		while ((SysTick->CTRL & 0x00010000)==0);
		SysTick->CTRL = 0;
	}
}
